//
//  ButtonView.m
//  太平洋电脑网
//
//  Created by dllo on 16/6/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ButtonView.h"
#define BUTTONWIDTH self.view.frame.size.width
#define BUTTONHEIGHT self.view.frame.size.height

@interface ButtonView ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,retain)NSArray *array;

@end

@implementation ButtonView
static NSString *const ButtonCell = @"buttonCell";
-(void)dealloc{
    [_array release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createConfig];
    [self createView];
}
- (void)createConfig{
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.87f green:0.87f blue:0.87f alpha:1.00f];
    self.array = @[@"手机",@"DIY",@"笔记本",@"摄影",@"Phone人院",@"二手",@"最数码",@"收藏板块"];
    self.title = self.array[self.value];
}
- (void)createView{
    if (self.value == 0 ||self.value == 1 ||self.value == 2 ||self.value == 3 ||self.value == 5 ||self.value == 6 ) {
        UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, BUTTONWIDTH, BUTTONHEIGHT - 64) style:UITableViewStylePlain];
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.contentInset = UIEdgeInsetsMake(110, 0, 0, 0);
        tableView.backgroundColor = [UIColor purpleColor];
        [self.view addSubview:tableView];
        [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:ButtonCell];
        for (int i = 0; i < 5; i++) {
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.frame = CGRectMake(10 + 80*i, -100, 70, 70);
            [tableView addSubview:button];
            button.backgroundColor = [UIColor yellowColor];
            UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(10 + 80*i, -25, 70, 20)];
            lable.backgroundColor = [UIColor orangeColor];
            [tableView addSubview:lable];
            [lable release];
         }
    }else if(self.value == 4){
        UIBarButtonItem *itemOfRight = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(oneAction:)];
        UIBarButtonItem *otherItemOfright = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self action:@selector(twoAction:)];
        self.navigationItem.rightBarButtonItems = @[itemOfRight,otherItemOfright];  //越靠前的越靠右
        [itemOfRight release];
        [otherItemOfright release];
    }else{
        
    }
    
}
//
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ButtonCell];
    return cell;
}









































- (void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.barTintColor =[UIColor colorWithRed:0.87f green:0.87f blue:0.87f alpha:1.00f];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
